const srcPath = process.cwd() + '\\src';
const resetCss = srcPath + '\\css\\reset.css';
const lessFilePath = srcPath+ '\\css\\index.less';


module.exports = {

  chainWebpack: config => {
    
      
    const VueLess = config.module.rule('less').oneOf('vue')
    const Less = config.module.rule('less').oneOf('vue-modules')

    Less.use('less-loader')
        .tap(options =>{
            options.javascriptEnabled = true;
            return options;
        })

    
    VueLess.use('less-loader')
            .tap(options =>{
                options.javascriptEnabled = true;
                return options;
            })


    // 全局less
    Less.use('sass-resources-loader')
            .loader('sass-resources-loader')
            .options({
                resources: [lessFilePath, resetCss]
            })
            
    VueLess.use('sass-resources-loader')
           .loader('sass-resources-loader')
           .options({
               resources: [lessFilePath]
           })
   
  },

  devServer: {
      proxy: `http://localhost:${process.env.PORT || 3000}`
  }

}